/**
 * 
 */

package com.wutianyi.interesting;

import java.util.Arrays;
import java.util.Iterator;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * @author wutianyi
 * 
 */
public class CopyOnWriterTest {

	public static void main(String[] args) {

		String[] content = new String[] {"test_1", "test_2", "test_3"};
		CopyOnWriteArrayList<String> list =
				new CopyOnWriteArrayList<String>(Arrays.asList(content));

		Iterator<String> itr = list.iterator();
		list.add("test_4");
		printItr(itr);
		
		itr = list.iterator();
		printItr(itr);
	}

	private static void printItr(Iterator<String> itr) {

		while(itr.hasNext()) {
			String c = itr.next();
			if(c.equals("test_2")) {
				
			}
		}
	}
}
